// Lindsay Gilmour
// Adam Lusch
// Dan Niceswanger
//
// Computer Graphics Project 2:
// Teapot racing!

#include "GhostRecord.h"
#include "PhysicsWorld.h"

GhostRecord::GhostRecord(string f)
{
	clearData();
	
	filename = f;
}

GhostRecord::~GhostRecord()
{
}

void GhostRecord::clearData()
{
	ghostData.clear();
}

void GhostRecord::recordGhost(Teapot * pot)
{
	ghostData.push_back(pot->getX());
	ghostData.push_back(pot->getZ());
	ghostData.push_back(pot->getHeading());
}

void GhostRecord::saveGhost(double total, vector <double> laps)
{
	ofstream ghostFile(filename.c_str(), ios_base::trunc);
	if (ghostFile.is_open())
	{
		cout << total << endl;
		ghostFile << total << endl;
		// record lap times
		for (unsigned int i = 0; i < laps.size(); i++)
		{
			cout << laps[i] << endl;
			ghostFile << laps[i] << endl;
		}
		for (unsigned int i = 0; i < ghostData.size(); i++)
		{
			ghostFile << ghostData[i] << endl;
		}
		ghostFile.close();
	}
}
